package org.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.example.domain.Discussion;

import java.util.List;

@Mapper
public interface DiscussionDao extends BaseMapper<Discussion> {

    @Select("select content from discussion_content where discussion_id = #{discussionId}")
    String getContentByDiscussionId(int discussionId);

    @Update("update discussion set click = click + 1 where id = #{discussionId}")
    int clickAdd(int discussionId);

    @Insert("insert into discussion_content(discussion_id,content) values (#{discussionId},#{content})")
    int setContentByDiscussionId(Integer discussionId, String content);

    @Update("update discussion_content set content = #{content} where discussion_id = #{discussionId}")
    int updateContentByDiscussionId(Integer discussionId, String content);

    @Delete("delete from discussion_content where discussion_id = #{discussionId}")
    int deleteContentByDiscussionId(Integer discussionId);

    @Update("update discussion set likes = likes + 1 where id = #{discussionId}")
    int LikeAdd(int discussionId);

    @Select("select distinct type from discussion")
    List<String> getTypes();
}
